package com.itheima.twodimensionalarray;

public class Demo3TwoDimensionalArray {
    public static void main(String[] args) {
        int[] arr01 = {11,22,33};
        int[] arr02 = {44,55,66};

        int[][] arr = {{77,88,88},{100,55,66}};
        int[][] array = {arr01,arr02};
        //遍历数组arr
        for (int i = 0; i < arr.length; i++) {
            for (int j = 0; j < arr[i].length; j++) {
                System.out.print(arr[i][j]+" ");
            }
        }
        System.out.println();
        //遍历数组array
        for (int i = 0; i < array.length; i++) {
            for (int j = 0; j < array[i].length; j++) {
                System.out.print(array[i][j]+" ");
            }
        }
        System.out.println();
        //获取数组arr中的最大值
        int max = arr[0][0];//假设二维数组中第一个数组的第一个数值为最大值
        for (int i = 0; i < arr.length; i++) {
            for (int j = 0; j < arr[i].length; j++) {
                if(arr[i][j] > max){
                    max=arr[i][j];
                }
            }
        }
        System.out.println("max = " + max);
        //对数组array中的数据求和
        int sum = 0;
        for (int i = 0; i < array.length; i++) {
            for (int j = 0; j < array[i].length; j++) {
                sum += array[i][j];
            }
        }
        System.out.println("sum = " + sum);
    }
}
